import CryptoJS from "crypto-js";

let secretKey = CryptoJS.enc.Utf8.parse("nsirblu3zntomp2r");
let ivHex = CryptoJS.enc.Utf8.parse("2023949154679226");
export const decrypt = (word) => {
	var decrypted = CryptoJS.AES.decrypt(word, secretKey, {
		iv: ivHex,
		mode: CryptoJS.mode.CBC,
		padding: CryptoJS.pad.Pkcs7
	});
	return decrypted.toString(CryptoJS.enc.Utf8);
}

export const encrypt = (data) => {

	let encrypt = CryptoJS.AES.encrypt(data, secretKey, {
		iv: ivHex, //iv偏移量 CBC需加偏移量
		mode: CryptoJS.mode.CBC, //CBC模式
		padding: CryptoJS.pad.Pkcs7 //padding处理
	});
	// debugger
	return encrypt.toString(); //加密完成后，转换成字符串
}